﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>考勤系统员工客户端</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css"
	href="<%=path%>/jquery-easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/jquery-easyui/themes/icon.css">
<script type="text/javascript"
	src="<%=path%>/jquery-easyui/jquery-1.8.0.js"></script>
<script type="text/javascript"
	src="<%=path%>/jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.json-2.4.js"></script>
<script type="text/javascript">
	var path = '${pageContext.request.contextPath}';

	function logout() {
		var href = path + '/user/logout/';
		window.location.href = href;
	}

	function showChangePasswordWin() {
		$('#winPassword').window('open');
	}

	function changePassword() {
		var oldPassword = $("#iptOldPassword").val();
		if (oldPassword == "") {
			$.messager.alert('提示', '请输入原始密码！');
			return;
		}

		var password = $("#iptPassword").val();
		if (password == "") {
			$.messager.alert('提示', '请输入新密码！');
			return;
		}

		var newPassword = $("#iptNewPassword").val();
		if (newPassword == "") {
			$.messager.alert('提示', '请确认密码！');
			return;
		}

		if (newPassword != password) {
			$.messager.alert('提示', '两次密码不一致，请重新输入！');
			return;
		}

		$.messager.progress({
			title : '请稍候',
			msg : '验证密码中，请稍候...'
		});

		var parm = {
			password : password,
			oldPassword : oldPassword
		};

		$.ajax({
			type : "POST",
			url : path + "/changedUserPassword/",
			data : parm,
			success : function(msg) {
				$.messager.progress('close');
				if (msg.isSucess) {
					$.messager.alert('提示', '修改成功！', "info", function() {
						$('#winPassword').window('close');
						$("#iptOldPassword").val("");
						$("#iptPassword").val("");
						$("#iptNewPassword").val("");
					});
				} else {
					$.messager.alert('提示', '密码错误，请重新输入！', "info");
				}
			},
			error : function() {
				$.messager.progress('close');
				$.messager.alert('错误', '修改失败！', "error");
			}
		});
	}

	function onSelect(title, index) {
		var tabs = $('#tabs');
		var tab = tabs.tabs('getTab', title);
		var options = tab.panel('options');
		if (options.content || !options.action) {
			return;
		}

		var path = '${pageContext.request.contextPath}';
		var content = '<iframe scrolling="yes" frameborder="0" src="' + path
				+ '/' + options.action
				+ '" style="width:100%;height:100%;"></iframe>';
		tabs.tabs('update', {
			tab : tab,
			options : {
				content : content
			}
		});
	}
</script>
</head>

<body class="easyui-layout">

	<div id="winPassword" class="easyui-window"
		data-options="closed:true,modal:true,title:'修改密码',collapsible:false,minimizable:false"
		style="width: 320px; height: 185px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center',border:false"
				style="padding: 10px; background: #fff; border: 1px solid #ccc;">
				<table>
					<tr>
						<td>原始密码：</td>
						<td><input type="password" id="iptOldPassword" /></td>
					</tr>
					<tr>
						<td>新密码：</td>
						<td><input type="password" id="iptPassword" /></td>
					</tr>
					<tr>
						<td>确认密码：</td>
						<td><input type="password" id="iptNewPassword" /></td>
					</tr>
				</table>
			</div>
			<div data-options="region:'south',border:false"
				style="text-align: right; height: 30px; line-height: 30px;">
				<a class="easyui-linkbutton"
					data-options="iconCls:'icon-ok',plain:false"
					href="javascript:void(0)" onclick="changePassword()"> 确定</a> <a
					class="easyui-linkbutton"
					data-options="iconCls:'icon-cancel',plain:false"
					href="javascript:void(0)"
					onclick="$('#winPassword').window('close');">取消</a>
			</div>
		</div>
	</div>

	<div id="tools">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			data-options="plain:true,iconCls:'icon-edit'"
			onclick="showChangePasswordWin()">修改密码</a> <a
			href="javascript:void(0)" class="easyui-linkbutton"
			data-options="plain:true,iconCls:'icon-back'" onclick="logout()">注销</a>
	</div>

	<div data-options="region:'center'">
		<div id="tabs" class="easyui-tabs"
			data-options="fit:true,tabPosition:'left',onSelect:onSelect,tools:'#tools'">
			<div title="工作时间查询" style="padding:10px"
				data-options="action:'private/schedule'"></div>
			<div title="个人刷脸记录查询" style="padding:10px"
				data-options="action:'private/card'"></div>
			<div title="个人年考勤查询" style="padding:10px"
				data-options="action:'private/worksum'"></div>
			<div title="个人特殊考勤" style="padding:10px"
				data-options="action:'private/special'"></div>
			<div title="个人请假查询 " style="padding:10px"
				data-options="action:'private/leave'"></div>
			<div title="个人刷脸统计表" style="padding:10px"
				data-options="action:'private/cardrecord'"></div>
			<%
				Object isAdmin = request.getSession().getAttribute("isAdmin");
				if (isAdmin != null) {
			%>
			<div title="员工刷脸记录查询" style="padding:10px"
				data-options="action:'public/card'"></div>
			<div title="员工月考勤查询" style="padding:10px"
				data-options="action:'public/worksum'"></div>
			<div title="员工特殊考勤" style="padding:10px"
				data-options="action:'public/special'"></div>
			<div title="员工请假查询 " style="padding:10px"
				data-options="action:'public/leave'"></div>
			<div title="月电子考勤统计表" style="padding:10px"
				data-options="action:'public/monthsum'"></div>
			<div title="员工刷脸统计表" style="padding:10px"
				data-options="action:'public/cardrecord'"></div>
			<%
				}
			%>
		</div>
	</div>
</body>
</html>